import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);
import vuexPersist from "vuex-persist";

export default new Vuex.Store({
  state: {
    data: [],
  },
  mutations: {
    setdata(state, res) {
      state.data = res;
    },
    change1(state, index) {
      state.data[index].status = 1;
    },
    all1(state) {
      state.data.forEach((item) => {
        if (item.status == 0) {
          item.status = 1;
        }
      });
    },
    //把未读全部标记已读
    all2(state) {
      state.data.forEach((item) => {
        if (item.status == 1) {
          item.status = 2;
        }
      });
    },
    //把全部已读删除

    all0(state) {
      state.data.forEach((item) => {
        if (item.status == 2) {
          item.status = 0;
        }
      });
    },
    //把回收站里的全部还原到未读
  },
  actions: {},
  modules: {},
  plugins: [
    new vuexPersist({
      storage: window.localStorage,
    }).plugin,
  ],
});
